package com.jwdf.uda.ui.fragment.stylist;

import com.jwdf.uda.R;
import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.event.StylistAnswerEvent;
import com.jwdf.uda.http.AHttpService;
import com.jwdf.uda.http.HttpHelper;
import com.jwdf.uda.http.action.UserRedPointAction;
import com.jwdf.uda.utils.EventBusUtil;
import com.jwdf.uda.utils.StringUtils;

import retrofit2.Response;

/**
 * 类说明：
 */
public class StylistAnswerFragment extends AbsStylistFragment{

    public static StylistAnswerFragment instance() {
        StylistAnswerFragment view = new StylistAnswerFragment();
        return view;
    }
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if(isVisibleToUser){
            EventBusUtil.post(StylistAnswerEvent.newInstance(false));
        }
    }
    @Override
    protected void initViews() {
        super.initViews();
        onNewRequestCall(UserRedPointAction.newInstance(getActivity()).request(new AHttpService.IResCallback<PbBean.PbResUserGetRedpoint>() {
            @Override
            public void onCallback(int resultCode, Response<PbBean.PbResUserGetRedpoint> response, PbBean.PbBaseServerInfo baseServerInfo) {
                if(getView()!=null) {
                    String errorMsg = HttpHelper.showErrorMsg(getContext(), resultCode, baseServerInfo, getString(R.string.error_net));
                    if (!StringUtils.isNullEmpty(errorMsg)) {
                        return;
                    }
                }
                EventBusUtil.post(StylistAnswerEvent.newInstance(response.body().getGuideWaitList()));
            }
        }));
    }
    @Override
    protected PbBean.PbSignGuideListFilterType getGuideListFilterType() {
        return PbBean.PbSignGuideListFilterType.GUIDE_LIST_FILTER_WAIT;
    }
}
